Path: blob/master/Part 8 - Deep Learning/Artificial Neural Networks/[R] Artificial Neural Network.ipynb
1009 views
Kernel: R
Artificial Neural Network
Like in Python, we will not have to use our own resource to train the ANN. Here we will use h2o package which connect to a server and train the ANN on that. More importantly h2o have parameter tunning feature which automatically tune the parameter as per requirement.
Data preprocessing
In [1]:
In [2]:
Out[2]:
In [3]:
In [4]:
Out[4]:
In [5]:
In [6]:
In [7]:
In [8]:
Out[8]:
In [9]:
Out[9]:
Fiting ANN to the Training set
In [10]:
In [11]:
Out[11]:
----------------------------------------------------------------------
Your next step is to start H2O:
> h2o.init()
For H2O package documentation, ask for help:
> ??h2o
After starting H2O, you can use the Web UI at http://localhost:54321
For more information visit http://docs.h2o.ai
----------------------------------------------------------------------
Attaching package: ‘h2o’
The following objects are masked from ‘package:stats’:
cor, sd, var
The following objects are masked from ‘package:base’:
&&, %*%, %in%, ||, apply, as.factor, as.numeric, colnames,
colnames<-, ifelse, is.character, is.factor, is.numeric, log,
log10, log1p, log2, round, signif, trunc
H2O is not running yet, starting it now...
Note: In case of errors look at the following log files:
/tmp/Rtmp8aN7Ch/h2o_baka_started_from_r.out
/tmp/Rtmp8aN7Ch/h2o_baka_started_from_r.err
Starting H2O JVM and connecting: ....... Connection successful!
R is connected to the H2O cluster:
H2O cluster uptime: 5 seconds 838 milliseconds
H2O cluster version: 3.16.0.2
H2O cluster version age: 27 days
H2O cluster name: H2O_started_from_R_baka_fmq912
H2O cluster total nodes: 1
H2O cluster total memory: 0.82 GB
H2O cluster total cores: 4
H2O cluster allowed cores: 4
H2O cluster healthy: TRUE
H2O Connection ip: localhost
H2O Connection port: 54321
H2O Connection proxy: NA
H2O Internal Security: FALSE
H2O API Extensions: XGBoost, Algos, AutoML, Core V3, Core V4
R Version: R version 3.4.2 (2017-09-28)
In [12]:
Out[12]:
|======================================================================| 100%
|======================================================================| 100%
Predicting the Test set results
In [13]:
Out[13]:
|======================================================================| 100%
|======================================================================| 100%
In [14]:
Out[14]:
In [15]:
Out[15]:
Making the Confusion Matrix
In [16]:
Out[16]:
y_pred
0 1
0 1530 63
1 218 189
Calculating Accuracy
In [17]:
Out[17]:
Disconnect from server
In [18]:
Out[18]:
Are you sure you want to shutdown the H2O instance running at http://localhost:54321/ (Y/N)? y